﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace YQGL.Common
{
    /// <summary>
    /// GetRootPath 的摘要说明
    /// </summary>
    public class GetRootPath : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            if ("/Common/GetRootPath.ashx".ToUpper() == context.Request.ServerVariables["SCRIPT_NAME"].ToUpper())
            {
                //无虚拟目录
                context.Response.Write("var rootPath=''");
            }
            else
            {
                string virtualPath = context.Request.ServerVariables["SCRIPT_NAME"];
                int tmpEnd = virtualPath.IndexOf("/", 1);
                context.Response.Write("var rootPath='" + virtualPath.Substring(0, tmpEnd) + "'");
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}